package com.sc.design.proxy.forceproxy;

public class GamePlayer implements IGamePlayer {
    private String name = "";
    private IGamePlayer proxy = null;

    GamePlayer(String _name){
        this.name = _name;
    }

    @Override
    public void killBoss() {
        if(isProxy()){
            System.out.println(name+"kill boss");
        }
        else{
            System.out.println("请指定代理");
        }
    }

    @Override
    public void upgrade() {
        if(isProxy()){
            System.out.println(name+"upgrade");
        }
        else{
            System.out.println("请指定代理");
        }
    }

    @Override
    public void login() {
        if(isProxy()){
            System.out.println(name+"login");
        }
        else{
            System.out.println("请指定代理");
        }
    }

    @Override
    public IGamePlayer getProxy() {
        this.proxy = new GamePlayerProxy(this);
        return this.proxy;
    }

    private Boolean isProxy(){
        if(this.proxy==null){
            return false;
        }else{
            return true;
        }
    }
}
